<template>
  <a-card :bordered="false" v-if='result'>
    <div @click="closeCurrent()" style="text-align: right;">
      <a-icon type="close-circle" :style="{ fontSize: '20px', color: '#ccc' }" />
    </div>
    <detail-list title="基础信息" :col="4">
      <detail-list-item term="预警时间">{{result.alarmTime}}</detail-list-item>
      <detail-list-item term="预警位置">{{result.alarmLocation}}</detail-list-item>
      <detail-list-item term="预警编号">{{result.alarmDeviceCode}}</detail-list-item>
      <detail-list-item term="预警级别">{{result.alarmLevel=='一级'?'故障':'报警'}}</detail-list-item>
      <!-- <detail-list-item term="预警类型"></detail-list-item>
      <detail-list-item term="健康类型"></detail-list-item> -->
      <detail-list-item term="预警名称">{{result.faultType}}</detail-list-item>
      <detail-list-item term="处理状态">{{result.status==1?'已处理':'未处理'}}</detail-list-item>
    </detail-list>
    <a-divider />
    <div class="title-text"> 预测分析</div>
    <div style="display:flex;">
      <span>预警原因：</span>
      <a-input style="width:70%;" type="textarea" :value="result.description" disabled :auto-size="{ minRows: 3, maxRows: 5 }"></a-input>
    </div>
    <a-divider />
    <div class="title-text"> 维护建议</div>
    <span>建议编号：{{result.suggestCode}}</span>
    <div style="display:flex;margin-top: 20px;">
      <span>建议内容：</span>
      <a-input style="width:70%;" type="textarea" :value="result.content" disabled :auto-size="{ minRows: 3, maxRows: 5 }"></a-input>
    </div>
    <a-divider />
    <a-row type="flex" justify="end">
      <a-col>
        <a-button style="margin-right:20px" @click="handleClose">关闭</a-button>
        <a-button type="primary" @click='handleDone' v-if='result.status==0'>确认已处理</a-button>
      </a-col>
    </a-row>
  </a-card>
</template>

<script>

import { httpAction, getAction } from '@/api/manage'
import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
import DetailList from '@/components/tools/DetailList'
const DetailListItem = DetailList.Item

export default {
  name: 'GdDeviceFaultAlarmForm',
  inject: ['closeCurrent'],
  components: {
    JDictSelectTag,
    DetailList,
    DetailListItem
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data() {
    return {
      model: {
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
      },
      url: {

      },
      result: null
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  created() {
    let id = this.$route.query.id
    this.getDetail(id)
  },
  methods: {
    getDetail(id) {
      getAction('/healthy/gdDeviceHealthyAlarm/queryDetailById', { id }).then(res => {
        if (res && res.code == 200) {
          console.log(res)
          this.result = res.result
        } else {
          this.$message.info("暂无数据")
        }
      })
    },
    handleDone() {
      getAction('/healthy/gdDeviceHealthyAlarm/healthyAlarmHandling', { 'id': this.result.id }).then(res => {
        if (res && res.code == 200) {
          this.$message.success(res.message)
          this.closeCurrent()
          this.$router.push('/prediction/healthWarning')
        }
      })
    },
    handleClose(){
      this.closeCurrent()
      this.$router.push('/prediction/healthWarning')

    }        

  }
}
</script>
<style lang="less" scoped>
.title-text {
  font-size: 16px;
  color: #000;
  font-weight: 700;
  margin-bottom: 20px;
}
/deep/ .detail-list {
  .title {
    color: #000;
    font-weight: 700;
  }
}
</style>